package com.eleventwelve.iris.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.opentides.bean.BaseEntity;
import org.opentides.bean.SystemCodes;

/**
 * 
 * @author Ashley
 *
 */
@Entity
@Table(name="TREATMENT")
@DiscriminatorValue("TREATMENT")
public class Treatment extends BaseEntity{
	private static final long serialVersionUID = -6295939599390220503L;

	@ManyToOne
	@JoinColumn(name="PATIENT_ID")
	private Patient patient;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="MEDICAL_PROCEDURE_ID")
	private MedicalProcedure procedure;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="PERFORMED_BY")
	private Staff performedBy;
	
	@OneToMany
	@JoinTable(name = "TREATMENT_ASSISTANT",
		joinColumns = { @JoinColumn(name="TREATMENT_ID", unique = true) },
	    inverseJoinColumns = { @JoinColumn(name="ASSISTANT_ID") }
	)
	private Set<Staff> assistants;
	
	@Temporal(TemporalType.DATE)
	@Column(name="TREATMENT_DATE")
	private Date treatmentDate;
	
	@Lob
	@Column(name="DESCRIPTION")
	private String description;
	
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="PRESCRIPTION_ID") 
	private Prescription prescription;
	
	@Lob
	@Column(name="RESULT")
	private String result;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="RESULT_STATUS")
	private SystemCodes resultStatus;

	public Patient getPatient() {
		return patient;
	}

	public void setPatient(Patient patient) {
		this.patient = patient;
	}

	public MedicalProcedure getProcedure() {
		return procedure;
	}

	public void setProcedure(MedicalProcedure procedure) {
		this.procedure = procedure;
	}

	public Staff getPerformedBy() {
		return performedBy;
	}

	public void setPerformedBy(Staff performedBy) {
		this.performedBy = performedBy;
	}

	public Set<Staff> getAssistants() {
		return assistants;
	}

	public void setAssistants(Set<Staff> assistants) {
		this.assistants = assistants;
	}

	public Date getTreatmentDate() {
		return treatmentDate;
	}

	public void setTreatmentDate(Date treatmentDate) {
		this.treatmentDate = treatmentDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Prescription getPrescription() {
		return prescription;
	}

	public void setPrescription(Prescription prescription) {
		this.prescription = prescription;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public SystemCodes getResultStatus() {
		return resultStatus;
	}

	public void setResultStatus(SystemCodes resultStatus) {
		this.resultStatus = resultStatus;
	}
	
}
